Applied patch from Peter Osterlund to simplify the code while keeping the
authorOwen Taylor <otaylor@redhat.com>
Thu, 3 Aug 2000 13:18:01 +0000 (13:18 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Thu, 3 Aug 2000 13:18:01 +0000 (13:18 +0000)
Thu Aug  3 09:17:06 2000  Owen Taylor  <otaylor@redhat.com>

        * gdk/gdkrectangle.c (gdk_rectangle_intersect): Applied patch from
        Peter Osterlund to simplify the code while keeping the
        functionality the same.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkrectangle.c

index 1c946cd112693823c55b89e1bc469b403a2cb28c..ba9958f54130f8d7c94d73851735bf3d4ab22914 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Aug  3 09:17:06 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkrectangle.c (gdk_rectangle_intersect): Applied patch from
+       Peter Osterlund to simplify the code while keeping the
+       functionality the same.
+
 Wed Aug  2 14:57:38 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Move
index 1c946cd112693823c55b89e1bc469b403a2cb28c..ba9958f54130f8d7c94d73851735bf3d4ab22914 100644 (file)
@@ -1,3 +1,9 @@
+Thu Aug  3 09:17:06 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkrectangle.c (gdk_rectangle_intersect): Applied patch from
+       Peter Osterlund to simplify the code while keeping the
+       functionality the same.
+
 Wed Aug  2 14:57:38 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Move
index 1c946cd112693823c55b89e1bc469b403a2cb28c..ba9958f54130f8d7c94d73851735bf3d4ab22914 100644 (file)
@@ -1,3 +1,9 @@
+Thu Aug  3 09:17:06 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkrectangle.c (gdk_rectangle_intersect): Applied patch from
+       Peter Osterlund to simplify the code while keeping the
+       functionality the same.
+
 Wed Aug  2 14:57:38 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Move
index 1c946cd112693823c55b89e1bc469b403a2cb28c..ba9958f54130f8d7c94d73851735bf3d4ab22914 100644 (file)
@@ -1,3 +1,9 @@
+Thu Aug  3 09:17:06 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkrectangle.c (gdk_rectangle_intersect): Applied patch from
+       Peter Osterlund to simplify the code while keeping the
+       functionality the same.
+
 Wed Aug  2 14:57:38 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Move
index 1c946cd112693823c55b89e1bc469b403a2cb28c..ba9958f54130f8d7c94d73851735bf3d4ab22914 100644 (file)
@@ -1,3 +1,9 @@
+Thu Aug  3 09:17:06 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkrectangle.c (gdk_rectangle_intersect): Applied patch from
+       Peter Osterlund to simplify the code while keeping the
+       functionality the same.
+
 Wed Aug  2 14:57:38 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Move
index 1c946cd112693823c55b89e1bc469b403a2cb28c..ba9958f54130f8d7c94d73851735bf3d4ab22914 100644 (file)
@@ -1,3 +1,9 @@
+Thu Aug  3 09:17:06 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkrectangle.c (gdk_rectangle_intersect): Applied patch from
+       Peter Osterlund to simplify the code while keeping the
+       functionality the same.
+
 Wed Aug  2 14:57:38 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Move
index 1c946cd112693823c55b89e1bc469b403a2cb28c..ba9958f54130f8d7c94d73851735bf3d4ab22914 100644 (file)
@@ -1,3 +1,9 @@
+Thu Aug  3 09:17:06 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkrectangle.c (gdk_rectangle_intersect): Applied patch from
+       Peter Osterlund to simplify the code while keeping the
+       functionality the same.
+
 Wed Aug  2 14:57:38 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_process_updates_internal): Move
index b3b17c43cccc0f7111f790833fe4f18f9ab35f06..499112d2dcda8b279e9e27bb5010100c449e41bd 100644 (file)
@@ -50,9 +50,8 @@ gdk_rectangle_intersect (GdkRectangle *src1,
                         GdkRectangle *src2,
                         GdkRectangle *dest)
 {
-  GdkRectangle *temp;
-  gint src1_x2, src1_y2;
-  gint src2_x2, src2_y2;
+  gint dest_x, dest_y;
+  gint dest_w, dest_h;
   gint return_val;
 
   g_return_val_if_fail (src1 != NULL, FALSE);
@@ -61,52 +60,20 @@ gdk_rectangle_intersect (GdkRectangle *src1,
 
   return_val = FALSE;
 
-  if (src2->x < src1->x)
-    {
-      temp = src1;
-      src1 = src2;
-      src2 = temp;
-    }
-  src1_x2 = src1->x + src1->width;
-  src2_x2 = src2->x + src2->width;
+  dest_x = MAX (src1->x, src2->x);
+  dest_y = MAX (src1->y, src2->y);
+  dest_w = MIN (src1->x + src1->width, src2->x + src2->width) - dest_x;
+  dest_h = MIN (src1->y + src1->height, src2->y + src2->height) - dest_y;
 
-  if (src2->x < src1_x2)
+  if (dest_w > 0 && dest_h > 0)
     {
-      dest->x = src2->x;
-
-      if (src1_x2 < src2_x2)
-       dest->width = src1_x2 - dest->x;
-      else
-       dest->width = src2_x2 - dest->x;
-
-      if (src2->y < src1->y)
-       {
-         temp = src1;
-         src1 = src2;
-         src2 = temp;
-       }
-      src1_y2 = src1->y + src1->height;
-      src2_y2 = src2->y + src2->height;
-
-      if (src2->y < src1_y2)
-       {
-         return_val = TRUE;
-
-         dest->y = src2->y;
-
-         if (src1_y2 < src2_y2)
-           dest->height = src1_y2 - dest->y;
-         else
-           dest->height = src2_y2 - dest->y;
-
-         if (dest->height == 0)
-           return_val = FALSE;
-         if (dest->width == 0)
-           return_val = FALSE;
-       }
+      dest->x = dest_x;
+      dest->y = dest_y;
+      dest->width = dest_w;
+      dest->height = dest_h;
+      return_val = TRUE;
     }
-
-  if (!return_val)
+  else
     {
       dest->width = 0;
       dest->height = 0;